/**
 * Copyright (C), 2001-2023, www.bosssof.com.cn
 * FileName: RedisTestController
 * Author: Administrator
 * Date: 2023-05-24 12:41:39
 * Description:
 * <p>
 * History:
 * <author> Administrator
 * <time> 2023-05-24 12:41:39
 * <version> 1.0.0
 * <desc> 版本描述
 */
package com.bosssoft.usercenter.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.Map;

/**
 * @ClassName: RedisTestController
 * @Description: 类的主要功能描述
 * @Author: Administrator
 * @Date: 2023-05-24 12:41
 **/
@Slf4j
@RestController
public class RedisTestController {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;
    @RequestMapping("/redis/demo/get/hash1")
    public String  testOpsHash(){
        String o=String.valueOf(redisTemplate.opsForHash().get("hashkey","1"));
//        Collection collections= roleResourceMap.values();
//        collections.stream().forEach(o -> log.info(o.toString()));
        log.info(o);
        return "OK";
    }
    @RequestMapping("/redis/demo/get/hash2")
    public String  testOpsHash2(){
        Map map=redisTemplate.opsForHash().entries("hashkey");
        Collection collections= map.values();
        collections.stream().forEach(o -> log.info(o.toString()));
        return "OK";
    }

    @RequestMapping("/redis/demo/set/string")
    public String  testOpsSetString(){
        redisTemplate.opsForValue().set("user:address","fuzhou.fujian");
        return "OK";
    }

    @RequestMapping("/redis/demo/get/string")
    public String  testOpsString(){
        String o=String.valueOf(redisTemplate.opsForValue().get("user:address"));
        log.info(o);
        return "OK";
    }
}
